package com.ruoyi.backstage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zzw.domain.RescueStrength;
import com.ruoyi.zzw.service.TRescueStrengthService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 救援力量Controller
 * 
 * @author ruoyi
 * @date 2023-12-06
 */
@RestController
@RequestMapping("/backstage/strength")
public class BackRescueStrengthController extends BaseController
{
    @Autowired
    private TRescueStrengthService tRescueStrengthService;

    /**
     * 查询救援力量列表
     */
    @PreAuthorize("@ss.hasPermi('system:strength:list')")
    @GetMapping("/list")
    public TableDataInfo list(RescueStrength rescueStrength)
    {
        startPage();
        List<RescueStrength> list = tRescueStrengthService.selectTRescueStrengthList(rescueStrength);
        return getDataTable(list);
    }

    /**
     * 导出救援力量列表
     */
    @PreAuthorize("@ss.hasPermi('system:strength:export')")
    @Log(title = "救援力量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RescueStrength rescueStrength)
    {
        List<RescueStrength> list = tRescueStrengthService.selectTRescueStrengthList(rescueStrength);
        ExcelUtil<RescueStrength> util = new ExcelUtil<RescueStrength>(RescueStrength.class);
        util.exportExcel(response, list, "救援力量数据");
    }

    /**
     * 获取救援力量详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:strength:query')")
    @GetMapping(value = "/{cRescueId}")
    public AjaxResult getInfo(@PathVariable("cRescueId") Long cRescueId)
    {
        return success(tRescueStrengthService.selectTRescueStrengthByCRescueId(cRescueId));
    }

    /**
     * 新增救援力量
     */
    @PreAuthorize("@ss.hasPermi('system:strength:add')")
    @Log(title = "救援力量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RescueStrength rescueStrength)
    {
        return toAjax(tRescueStrengthService.insertTRescueStrength(rescueStrength));
    }

    /**
     * 修改救援力量
     */
    @PreAuthorize("@ss.hasPermi('system:strength:edit')")
    @Log(title = "救援力量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RescueStrength rescueStrength)
    {
        return toAjax(tRescueStrengthService.updateTRescueStrength(rescueStrength));
    }

    /**
     * 删除救援力量
     */
    @PreAuthorize("@ss.hasPermi('system:strength:remove')")
    @Log(title = "救援力量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cRescueIds}")
    public AjaxResult remove(@PathVariable Long[] cRescueIds)
    {
        return toAjax(tRescueStrengthService.deleteTRescueStrengthByCRescueIds(cRescueIds));
    }
}
